package com.nuaa.ange.controller;

import com.nuaa.ange.annotation.ApiLog;
import com.nuaa.ange.common.lang.RespBean;
import com.nuaa.ange.entity.User;
import com.nuaa.ange.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description
 * @author 玦离
 * @date 2022/12/31 19:11
 */

@RestController
@Api(tags = "用户相关接口")
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    /**
     * 更新用户信息
     * @param user
     * @return
     */
    @ApiOperation(value = "更新用户信息")
    @PostMapping("/info")
    @ApiLog
    public RespBean updateUserInfo(@RequestBody User user) {
        userService.updateById(user);
        return RespBean.ok("用户信息更新成功", user);
    }
}
